﻿
using HandyControl.Controls;
using HandyControl.Data;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using wms_wpf.Apiservice;
using wms_wpf.DialogView;
using wms_wpf.InPut;

namespace wms_wpf.DialogViewModel
{
   public class Dialog1ViewModel : BindableBase
    {

        public Dialog1ViewModel(IBaseService service)
        {
            this.service = service;
            ConfirmCommand=new DelegateCommand(Confirm);
            InPut_BaseService = new InPut_BaseService3();
        }
        private readonly IBaseService service;
        public  DelegateCommand ConfirmCommand { get; set; }
        private InPut_BaseService3 inPut_BaseService;
        public InPut_BaseService3 InPut_BaseService 
        {
            get { return inPut_BaseService; }
            set { inPut_BaseService = value; RaisePropertyChanged(); }
        }
        private bool isrunning;
        public bool Isruning
        {
            get { return isrunning; }
            set { isrunning = value; RaisePropertyChanged(); }
        }
        private Visibility visibility = Visibility.Hidden;
        public Visibility Visibility
        {
            get { return visibility; }
            set { visibility = value;RaisePropertyChanged(); }
        }
        private async void Confirm()
        {
             bool res=  InPut_BaseService.GetType().GetProperties().All(property => property.GetValue(InPut_BaseService) != null);
            if (!res)
            {
                Growl.Info("数据不完整！", "msg");
                return;
            }
            Isruning = true;
            Visibility=Visibility.Visible;
            await service.Create_Warehouses(InPut_BaseService);
            Visibility = Visibility.Hidden;
            Isruning =false;
      
            
        }
    }
}
